/**
 * 时间对象的格式化;
 */
Date.prototype.format = function(format) {
	/*
	 * eg:format="YYYY-MM-dd hh:mm:ss";
	 */
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
	// millisecond
	}

	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	}

	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
}

/** 修改后的用于js对象序列化的方法* */
function _ToJSON(o) {
	if (o == null)
		return "null";

	switch (o.constructor) {
	case String:
		var s = o; // .encodeURI();
		if (s.indexOf("}") < 0)
			s = '"' + s.replace(/(["\\])/g, '\\$1') + '"';
		s = s.replace(/\n/g, "\\n");
		s = s.replace(/\r/g, "\\r");
		return s;
	case Array:
		var v = [];
		for ( var i = 0; i < o.length; i++)
			v.push(_ToJSON(o[i]));
		if (v.length <= 0)
			return "\"\"";
		return "" + v.join(",") + "";
	case Number:
		return isFinite(o) ? o.toString() : _ToJSON(null);
	case Boolean:
		return o.toString();
	case Date:
		var d = new Object();
		d.__type = "System.DateTime";
		d.Year = o.getUTCFullYear();
		d.Month = o.getUTCMonth() + 1;
		d.Day = o.getUTCDate();
		d.Hour = o.getUTCHours();
		d.Minute = o.getUTCMinutes();
		d.Second = o.getUTCSeconds();
		d.Millisecond = o.getUTCMilliseconds();
		d.TimezoneOffset = o.getTimezoneOffset();
		return _ToJSON(d);
	default:
		if (o["toJSON"] != null && typeof o["toJSON"] == "function")
			return o.toJSON();
		if (typeof o == "object") {
			var v = [];
			for (attr in o) {
				if (typeof o[attr] != "function")
					v.push('"' + attr + '": ' + _ToJSON(o[attr]));
			}

			if (v.length > 0)
				return "{" + v.join(",") + "}";
			else
				return "{}";
		}
		alert(o.toString());
		return o.toString();
	}
};

RoomAll = function() {
	
	this.roomList = new Array();// 
};

SceneDeviceAll = function(){
	this.sceneId = 0;
	this.sceneName = "";
	this.deviceList = new Array();
}
